#ifndef NET_TCP_SERVER_H_
#define NET_TCP_SERVER_H_

#include "base/base.h"

namespace net {
class TcpStream;
class Acceptor;
class Poller;
class PollThreadPool;
class Processor;
class Socket;

class TcpServer {
  public:
    TcpServer(Poller* base_poll, const std::string& ip, uint16 port);
    virtual ~TcpServer();

    void SetProcessor(Processor* processor);

    void Start();

    TcpStream* AddConnection(Socket* sock);
    void RemoveConnection(void* stream);

  private:
    const std::string ip_;
    const uint16 port_;
    scoped_ptr<Poller> base_poller_;

    scoped_ptr<Acceptor> acceptor_;
    scoped_ptr<PollThreadPool> poll_thread_pool_;
    Mutex mutex_map_;
    std::map<int32, TcpStream*> stream_map_;

    scoped_ptr<Processor> processor_;

    DISALLOW_COPY_AND_ASSIGN(TcpServer);
};
}

#endif
